<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <title>Foto galeria</title>
    <link rel="shortcut icon" href="favicon.ico" />
    <link href="style/style.css" rel="stylesheet" type="text/css" />
    <link href="style/menu.css" rel="stylesheet" type="text/css" />
    <meta http-equiv="content-type" content="text/html; charset=UTF-8" />                        
  </head>
  <body>
  <div id="page">
    <?php
      echo "<div id='hlavicka'>";
      include("menu.php");
      echo "<a href='index.php'>Main</a>";
      echo "</div>";
      include("includes/conf.inc.php");
      include("includes/function.php");
      if (isset($_GET['imgID']))
      {
        $imgID = $_GET['imgID'];
      }
      else
      {
        $imgID = 1;
      }
      
      DBConnect();
      
      $query = "SELECT link, description FROM $gal_tbl WHERE id = '$imgID'" ;
      $res = mysql_query($query);
      if (mysql_num_rows($res) == 1)
      {
          $obj = mysql_fetch_object($res);
          $file = "./images/gallery/".$obj->link;
          list ($w, $h) = getimagesize($file);
          if ($w > 800)
          {
            $w = 800;
          }
          
          echo "<div id='telo' style='float:none; text-align:center;'>";
          echo "<img src='./images/gallery/", $obj->link, "' alt='", $obj->description, "' width='", $w, "' />";
          echo "</div>";
          echo "<div style='text-align:center; float:none;width:800;height:auto;border-style:solid; border:5px'>";
          echo $obj->description;
          
          $query = "SELECT * FROM $discuz_tbl WHERE id_img = '$imgID' ORDER BY id ASC";
          $res = mysql_query($query);
          while ($obj = mysql_fetch_object($res))
          {
            echo "<p>";
            echo $obj->sender,":<br />";
            echo $obj->comment;
            echo "<hr size='1' width=800 />";
            echo "</p>";
          }
          echo "<form action='comment.php' enctype='multipart/form-data' method='post'>";
          echo "<input type='hidden' name='imgID' value='", $imgID, "' />";
          echo "<textarea name='comment' cols='50'></textarea><br />";
          echo "<input type='submit' value='comment' />";
          echo "</form>";
          echo "</div>";
      }
      else
      {
        echo "Image not found in DB! ";
      }
    ?>
  </div>
</body>
</html>